package org.extreme.model.reports.core;

import java.util.ArrayList;
import java.util.List;

import org.extreme.model.cell.CellElement;

public class FamilyMember {
	CellElement current;
	FamilyMember leftParent;
	FamilyMember upParent;
	List<FamilyMember> sons;
	
	FamilyMember(CellElement current, FamilyMember left, FamilyMember up) {
		this.current = current;
		this.leftParent = left;
		this.upParent = up;
	}
	
	public void addSon(FamilyMember son) {
		if (this.sons == null) {
			this.sons = new ArrayList<FamilyMember>();
		}
		
		this.sons.add(son);
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("{self:").append(current);
		if (leftParent != null) {
			sb.append(", left:").append(leftParent.current);
		}
		if (upParent != null) {
			sb.append(", up:").append(upParent.current);
		}
		sb.append("}");

		return sb.toString();
	}
}
